package modelLayer;

/**
 * This class is a modelLayer class of the MSAS system. It holds
 * information on a single teacher. True to our domain model, the teacher
 * class has no field visibility to any class.
 * 
 * @author Danny M�lgaard, Anna Kelemen, Jakob Korsgaard
 * 		   
 * @version 1.3.1
 * 					1.3.1: 		Added more extensive documentation. Verified that
 * 								information contained in the Design Class Diagram,
 * 								is in accordance with the information contained in this
 * 								class.
 *					1.3.2:		toString() adjusted	
 */
public class Teacher {
	
	private int id;
	private int hours;
	private String name;
	private String cpr;
	private String address;
	private String phone;
	private String email;

	/**
	 * Instantiating a Teacher object, taking no parameters.
	 */
	public Teacher() {		
	}

	/**
	 * Instantiating a Teacher object, taking the following parameters:
	 * 
	 * @param	id			int		the identification number of a teacher,
	 * 								as allocated in the database.
	 */
	public Teacher(int id) {
		
		this.setId(id);
		
	}

	/**
	 * Instantiating a Teacher object, taking the following parameters:
	 * 
	 * @param	name		String	the name of the teacher.
	 * @param 	cpr			String	the SSN of the teacher.
	 * @param 	address		String	the address of teacher's residence.
	 * @param 	phone		String	teacher's phone number.
	 * @param 	email		String	teacher's e-mail.		
	 * @param	hours		int		number of hours per week the teacher works.
	 */
	public Teacher(String name, String cpr, String address, String phone,
				   String email, int hours) {

		this.setName(name);
		this.setCpr(cpr);
		this.setAddress(address);
		this.setPhone(phone);
		this.setEmail(email);
		this.setHours(hours);
		
	}

	/**
	 * Assigns a parameter to the hours field.
	 * 
	 * @param 	hours	int		the number of hours per week the teacher works.					
	 */
	public void setHours(int hours) {

		this.hours = hours;
	
	}
	
	/**
	 * Assigns a parameter to the cpr field.
	 * 
	 * @param 	cpr			String	the ssn of the teacher.					
	 */
	public void setCpr(String cpr) {

		this.cpr = cpr;

	}
	
	/**
	 * Assigns a parameter to the address field.
	 * 
	 * @param 	address		String	the address of the teacher.					
	 */
	public void setAddress(String address) {

		this.address = address;

	}
	
	/**
	 * Assigns a parameter to the phone field.
	 * 
	 * @param 	phone	String	the phone number of the teacher.					
	 */
	public void setPhone(String phone) {

		this.phone = phone;

	}
	
	/**
	 * Assigns a parameter to the email field.
	 * 
	 * @param 	email	String	the email of the teacher.					
	 */
	public void setEmail(String email) {

		this.email = email;

	}
	
	/**
	 * Assigns a parameter to the name field.
	 * 
	 * @param 	name		String	the name of the teacher.					
	 */
	public void setName(String name) {

		this.name = name;

	}
	
	/**
	 * Assigns a parameter to the id field, defining the, by the database allocated, id
	 * of the teacher.
	 * 
	 * @param 	id			int		the id the teacher in the database.					
	 */
	public void setId(int id) {

		this.id = id;

	}
		
	/**
	 * Returns the teacher's hours per week to the caller.
	 * 
	 * @return	hours	int		the number of hours per week the teacher works.
	 */
	public int getHours() {
		
		return this.hours;
		
	}

	/**
	 * Returns teacher's ssn to the caller.
	 * 
	 * @return	cpr		String		ssn of the teacher.
	 */
	public String getCpr() {
	
		return this.cpr;

	}

	/**
	 * Returns teacher's address to the caller.
	 * 
	 * @return	address		String		address of the teacher.
	 */
	public String getAddress() {

		return this.address;

	}

	/**
	 * Returns teacher's phone number to the caller.
	 * 
	 * @return	phone	String		phone number of the teacher.
	 */
	public String getPhone() {

		return this.phone;

	}

	/**
	 * Returns teacher's email to the caller.
	 * 
	 * @return	email	String		email of the teacher.
	 */
	public String getEmail() {

		return this.email;

	}

	/**
	 * Returns the teacher's name  to the caller.
	 * 
	 * @return	name	String		name of the teacher.
	 */
	public String getName() {

		return this.name;

	}

	/**
	 * Returns teacher's id, as allocated in the database, to the caller.
	 * 
	 * @return	id	int		id of the teacher.
	 */
	public int getId() {

		return this.id;

	}

	/**
	 * Overrides the object's default toString() method. Returns the object as a String
	 * literal to the caller.
	 * 
	 * return				String	the Teacher object represented as a String object.
	 */
	@Override
	public String toString() {
		
		return "" + this.name;
	}
		
	/**
	 * Implements a check, to verify if an object is the same
	 * as this object. Uses student identification number to
	 * verify.
	 * 
	 * @param	o		Object	any object type.
	 * @return	true			if: 
	 * 							object is not null, and
	 * 							object is of type Teacher, and
	 * 							object id field matches this objects id field.
	 * @return	false			if:
	 * 							object is null, or
	 * 							object is not an instance of Teacher, or
	 * 							object id field doesn't match this objects id field.
	 */
	public boolean equals(Object o) {
		
		if (o != null && (o instanceof Teacher)){
			Teacher t = (Teacher) o;
			if (this.id == t.getId()) {
				return true;
			}
		}
			
		return false;

	}	
	
}
